package ipmsg.gui;

import javax.swing.GroupLayout;

public class ReadyToSendFiles extends javax.swing.JFrame {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2818272318359638294L;

	private javax.swing.JButton jButton1;
	private javax.swing.JButton jButton2;
	private javax.swing.JButton jButton3;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JList jList1;
	private javax.swing.JList jList2;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JPanel jPanel2;
	private javax.swing.JPanel jPanel3;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JSeparator jSeparator1;

	public ReadyToSendFiles() {
		initComponents();
		this.jList1.setListData(ipmsg.etc.GlobalVar.exportPacketNo());
		this.jLabel1.setText("接收方IP : ");
		this.jLabel2.setText("接收方姓名 : ");
	}

	private void initComponents() {
		this.jPanel1 = new javax.swing.JPanel();
		this.jScrollPane1 = new javax.swing.JScrollPane();
		this.jList1 = new javax.swing.JList();
		this.jPanel2 = new javax.swing.JPanel();
		this.jScrollPane2 = new javax.swing.JScrollPane();
		this.jList2 = new javax.swing.JList();
		this.jLabel1 = new javax.swing.JLabel();
		this.jLabel2 = new javax.swing.JLabel();
		this.jSeparator1 = new javax.swing.JSeparator();
		this.jPanel3 = new javax.swing.JPanel();
		this.jButton1 = new javax.swing.JButton();
		this.jButton2 = new javax.swing.JButton();
		this.jButton3 = new javax.swing.JButton();

		setDefaultCloseOperation(2);

		this.jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("编号"));

		this.jList1.setSelectionMode(0);
		this.jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
			public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
				ReadyToSendFiles.this.jList1ValueChanged(evt);
			}
		});
		this.jScrollPane1.setViewportView(this.jList1);

		GroupLayout jPanel1Layout = new GroupLayout(this.jPanel1);
		this.jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(this.jScrollPane1, -1, 119, 32767));

		jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addComponent(this.jScrollPane1, -1, 232, 32767));

		getContentPane().add(this.jPanel1, "Before");

		this.jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("详细信息"));

		this.jScrollPane2.setViewportView(this.jList2);

		this.jLabel1.setText("IP:");

		this.jLabel2.setText("姓名：");

		GroupLayout jPanel2Layout = new GroupLayout(this.jPanel2);
		this.jPanel2.setLayout(jPanel2Layout);
		jPanel2Layout
				.setHorizontalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
						.addComponent(this.jScrollPane2, -1, 291, 32767)
						.addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
								.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
										.addComponent(this.jSeparator1, -1, 271, 32767)
										.addGroup(jPanel2Layout
												.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
												.addComponent(this.jLabel2, javax.swing.GroupLayout.Alignment.LEADING,
														-1, -1, 32767)
												.addComponent(this.jLabel1, -1, 242, 32767)))
								.addContainerGap()));

		jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(jPanel2Layout.createSequentialGroup().addComponent(this.jLabel1)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jLabel2)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(this.jSeparator1, -2, 2, -2)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
						.addComponent(this.jScrollPane2, -1, 182, 32767)));

		getContentPane().add(this.jPanel2, "Center");

		this.jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("控制"));

		this.jButton1.setText("刷新");
		this.jButton1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				ReadyToSendFiles.this.jButton1ActionPerformed(evt);
			}

		});
		this.jButton2.setText("删除");

		this.jButton3.setText("关闭");
		this.jButton3.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				ReadyToSendFiles.this.jButton3ActionPerformed(evt);
			}

		});
		GroupLayout jPanel3Layout = new GroupLayout(this.jPanel3);
		this.jPanel3.setLayout(jPanel3Layout);
		jPanel3Layout.setHorizontalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(jPanel3Layout.createSequentialGroup().addContainerGap().addComponent(this.jButton1)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jButton2)
						.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(this.jButton3)
						.addContainerGap(233, 32767)));

		jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGroup(jPanel3Layout.createSequentialGroup()
						.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
								.addComponent(this.jButton1).addComponent(this.jButton2).addComponent(this.jButton3))
						.addContainerGap(-1, 32767)));

		getContentPane().add(this.jPanel3, "South");

		java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		setBounds((screenSize.width - 450) / 2, (screenSize.height - 356) / 2, 450, 356);
	}

	private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		this.jList1.setListData(ipmsg.etc.GlobalVar.exportPacketNo());
		this.jList2.setModel(new javax.swing.DefaultListModel());
		this.jLabel1.setText("接收方IP : ");
		this.jLabel2.setText("接收方姓名 : ");
	}

	private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {
		if (evt.getValueIsAdjusting()) {
			return;
		}
		if (this.jList1.getSelectedIndices().length == 1) {
			int packetNo = Integer.parseInt((String) this.jList1.getSelectedValue());
			ipmsg.etc.FileLinkList flist = ipmsg.etc.GlobalVar.getFileList(packetNo);
			if (flist == null)
				return;
			this.jLabel1.setText("接收方IP : " + flist.getIp());
			this.jLabel2.setText("接收方姓名 : " + ipmsg.etc.GlobalVar.getUser(flist.getIp()).getName());

			this.jList2.setListData(flist.exportFileList());
		}
	}

	private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
		dispose();
	}

	private void loadFileList() {
		this.jList1.setListData(ipmsg.etc.GlobalVar.exportPacketNo());
	}
}
